import React from 'react';
import {useParams} from 'react-router-dom';
import {useTags} from 'hooks/useTags';
import {SettingLayout} from 'components/SettingLayout';
import {TagContent} from './TagContent';
import {NoInfoError} from '../../components/NoInfoError';

type Params = {
  tagIdString: string;
}

const TagEditor: React.FC = () => {
  const {tagIdString} = useParams<Params>();
  const {findTag} = useTags();
  const tag = findTag(parseInt(tagIdString));
  return (
    <SettingLayout title="编辑标签">
      {tag ? <TagContent tag={tag}/> : <NoInfoError text="标签不存在" />}
    </SettingLayout>
  );
};

export {TagEditor};